/**
 * Created by zzc on 2017/12/19
 */


'use strict'

import {PageStatus} from "../Constants";

const initialState = {
    status: "",
    msg: " ",
    response: null
}

export default function requestStatus(state = initialState, action) {
    switch (action.type) {
        case PageStatus.LOADING: // 正在加载
            return {
                status: PageStatus.LOADING,
                msg: action.msg,
                response: null
            }
        case PageStatus.ERROR:   // 数据出错
            return{
                status: PageStatus.ERROR,
                msg: action.msg,
                response: action.response
            }
        case PageStatus.NETWORK_ERROR: // 网络出错
            return{
                status: PageStatus.NETWORK_ERROR,
                msg: action.msg,
                response: null
            }
        case PageStatus.SUCCESS: // 请求成功
            return{
                status: PageStatus.SUCCESS,
                msg: action.msg,
                response: action.response
            }
        case PageStatus.EMPTY: // 数据为空
            return{
                status: PageStatus.EMPTY,
                msg: action.msg,
                response: action.response
            }
        default:
            return state;
    }
}